%!TEX root = ./fuzzylite-1.01.tex
\chapter{Overview}

\section{Introduction}

\fl\ is a multiplatform, free, and open-source Fuzzy Logic Control Library written in C++ and released under the Apache License 2.0, which makes this software freely available for commercial and non-commercial use. The idea behind this library is to have a very simple and light-weight fuzzy controller. Simple as in simple to use, simple to understand, and simple to extend, without sacrificing performance. And light-weighted because it requires no additional libraries other than the Standard Template Library included in the C++ Standard Library. It has an object-oriented approach and a clear separation between the headers and sources, so it is easy to extend. Furthermore, it is GUI-agnostic, meaning that the library does not require a GUI to run, encouraging its use as a library. Nonetheless, a Qt-based GUI is also provided using \fl\ as an external library.

\section{Features}
\begin{itemize}
	\item Linguistic terms are continuous and the following ones are available: triangular, trapezoidal, rectangular, shoulder, singleton, custom function, and compound (multiple functions).
	\item Export any fuzzy system to text using a slightly modified version of the Fuzzy Controller Language (FCL).
	\item Defuzzification using center of gravity (COG). 
	\item Mamdani rule parsing with grammar checking.
	\item Takagi Sugeno rules of any order (e.g. f(x) = (sin x) / x, f(x) = 0.5 * input-1).
	\item Weights for each rule.
	\item TNorm: minimum, product, bounded difference. 
	\item SNorm: maximum, sum, bounded sum. 
	\item Modulation: clipping, scaling. 
	\item Aggregation: maximum, sum, bounded sum.
	\item Variable sampling size for membership functions to compute area and centroid.
	\item Triangulation and Trapezoidal algorithms to compute the area and
	centroid.
	\item Hedges: not, somewhat, very, any. 
	\item Very easy to implement and incorporate new linguistic terms, defuzzification methods, fuzzy rules (antecedents and consequents), fuzzy operations (T-Norms, S-Norms, methods for modulation and aggregation), algorithms for computing the area and centroid of linguistic terms, hedges, among other things.
	
\end{itemize}

\section{What's new?}
	\subsection{\fl}
	\begin{itemize}
		\item Fixed the Trapezoidal Algorithm.
		\item Changed most of the \#\texttt{include}s for forward declarations.
		\item Moved repository to \url{http://code.google.com/p/fuzzylite/}.
		\item Updated the building scripts for Unix systems.
		\item Removed building scripts for Mac OS X due to the lack of access to such OS.
	\end{itemize}
	
	\subsection{\texttt{FuzzyLite v.1.03}}
	\begin{itemize} 
	  \item Fixed the Triangulation Algorithm to include the first and last
	  triangle (improved accuracy). Courtesy of rctaylor.
	  \item Implemented the Trapezoidal Algorithm suggested by William Roeder,
	  although its accuracy is not as good as the Triangulation algorithm.
	  \item Created the scripts for building fuzzylite as static and dynamic
	  library, as well as building a demo version of it. Tested on Linux Ubuntu and
	  Mac OS X 10.5. Although the Unix version should work under Windows as well
	  using G++.
	  \item Added LeftShoulderTerm and RightShoulderTerm, just to provide a better
	  understanding when configuring the FuzzyEngine.
	  \item Changed all the \texttt{\#include <fuzzylite/?.h> for ``
	  fuzzylite/?.h''}.
	  \item Included the Trapezoidal Algorithm into the GUI.
	\end{itemize}

	\subsection{\texttt{FuzzyLite v.1.01}}
	\begin{itemize}
		\item 	The source can be built on Linux with no need to add several includes to some files. (I work on MacOSX and I did not build fuzzylite on Linux, I just assumed it would build just fine, but some includes were missing in some files. This was FIXED).
	\item Several scripts for building fuzzylite using a simple make. These scripts are created automatically by NetBeans, however, you do not need NetBeans to build fuzzylite nor the gui. The scripts are available for Linux and Mac OS X.
	\end{itemize}
	
	\subsection{\texttt{FuzzyLite v1.0}}
	\begin{itemize}
		% \item New linguistic terms available: sigmoidal, gaussian, sine and cosine functions.
		\item The GUI is working again.
		\item A class diagram of \fl.
		\item A detailed explanation of \fl.
		\item Minor changes.
	\end{itemize}

\section{What's next?}
	\begin{itemize}
	  \item Figure out why the accuracy of the Trapezoidal Algorithm is not as good
	  as the Triangulation algorithm.
		\item Fix the GUI so Takagi Sugeno rules can be tested with their respective graph.
		\item Improve the \texttt{InfixToPostfix} class so infix functions are parsed as one would normally expect.
		\item Load the fuzzy engine from text using the Fuzzy Controller Language (FCL).
		\item Include more linguistic terms (e.g. sigmoidal, gaussian, sine, cosine).
		\item Include more defuzzifiers (e.g. Right Most Maximum, Left Most Maximum, Mean Maximum).
		\item Make some functions inline to increase performance and check those that are already inline to ensure they do increase performance.
	\end{itemize}
	
	\section{Known bugs}
	\begin{itemize}
	
	  \item The Trapezoidal Algorithm had a bug in version 1.03. This bug has been fixed from version 1.5.
		\item \texttt{InfixToPostfix} conversion might not parse functions as one would normally expect. For example, $\sin (x) / x$ is \emph{not} equivalent to $(\sin x) / x$, the latter yields the result one might expect. Make sure by validating the postfix expression, or by evaluating its results.
		\item In the GUI, when using a Takagi Sugeno system, the output graphs do not work.
	\end{itemize}
	
\section{Building as a project}

The sources can be built by creating a project on your favorite C++ IDE. All you need to remember is to add `\texttt{./}' to the INCLUDE\_PATH since all the \texttt{\#include}s from the library are in the form \texttt{\#include 'fuzzylite/...'}. You will also need to specify whether is an application you are building from fuzzylite or a library (either static or dynamic). Additional settings involve activating the preprocessor directive `\texttt{FL\_USE\_LOG}' so you can output messages to the console (useful for the demo).

\section{Building from source}

Alternatively, you can build the library using the scripts provided which were created automatically from the Eclipse IDE once the previous parameters were set. Building from the scripts is shown below.

\subsection{\fl}
Inside \texttt{./fuzzylite} there are now 3 folders, on each there is a
	\texttt{makefile}. So all you have to do is execute from the folder the
	command \texttt{make}. The folders are described below.
	\begin{itemize}	
	  \item \texttt{unix-demo}: Builds a demo version of \texttt{fuzzylite} which
	  can be executed later as \texttt{./fuzzylite}. It shows the results for four
	  examples of Fuzzy Engines.
	  \item \texttt{unix-static}: Builds the library as a static library
	  (\texttt{fuzzylite.a}).
	  \item \texttt{unix-dynamic}: Builds the library as a dynamic library
	  (\texttt{fuzzylite.so}.
\end{itemize}

\subsection{\texttt{FuzzyLite v.1.03}}
	Inside \texttt{./fuzzylite} there are 6 folders, on each there is a
	\texttt{makefile}. So all you have to do is execute from the folder the
	command \texttt{make}. The folders are described below (notice that
	\texttt{[OS]} stands for the operating system).
	\begin{itemize}	
	  \item \texttt{[OS]-demo}: Builds a demo version of \texttt{fuzzylite} which
	  can be executed later as \texttt{./fuzzylite}. It shows the results for four
	  examples of Fuzzy Engines.
	  \item \texttt{[OS]-static}: Builds the library as a static library
	  (\texttt{fuzzylite.a}).
	  \item \texttt{[OS]-shared}: Builds the library as a dynamic library
	  (\texttt{fuzzylite.so} (unix) or \texttt{fuzzylite.dylib} (mac)).
\end{itemize}

	This is a huge improvement from those really nasty NetBeans scripts. These
	scripts were automatically created by Eclipse.

\subsection{\texttt{FuzzyLite v.1.01}}

	Version 1.01 contains the following files \texttt{linux-Makefile} and \texttt{macosx-Makefile}, and the following folders \texttt{linux-nbproject} and \texttt{macosx-nbproject}. Depending on your platform, you must rename them by removing the name of the platform, so the new names are \texttt{Makefile} and \texttt{nbproject} respectively. This should work, otherwise, follow the steps below.

	\begin{enumerate}
		\item Create a \texttt{C++} Project either in Eclipse IDE or Netbeans IDE.
		\item Add all the source files and include files to the project.
		\item Add \texttt{.} to the includes path in the project properties.
		\item Add the directive \texttt{-DFL\_USE\_LOG} to enable the use of logging via \texttt{FL\_LOG(message)}. In \texttt{./include/defs.h} there are more symbols that can be defined via \texttt{-D} for further customization.
		\item Decide whether to build a library or an executable (in project properties).
		\item Use the IDE's normal build.
	\end{enumerate}

\subsection{Graphic User Interface}
	\subsection{Requirements}
	\begin{itemize}
	  \item \texttt{Qt} which can be freely downloaded from
	  \url{http://qt.nokia.com/}.
	  
\end{itemize}
	\subsection{\fl}
		Building from source is the same as previous version.
		
	\subsection{\texttt{FuzzyLite v.1.03}}
	In order to build this version, all you need to do (aside from having
	installed \texttt{Qt} which can be freely downloaded from
\url{http://qt.nokia.com/}.) is execute from \texttt{./fuzzylite/} the command
\texttt{qmake}. This will create a Makefile. Then, run \texttt{make} and it
should start building the GUI. Notice that in \texttt{gui.pro} it links
 to the \texttt{unix} version of \texttt{fuzzylite} static library using
 relative path, so be sure to build such library first. If it is not
 \texttt{unix} what you need, perform your changes accordingly.

	\subsection{\texttt{FuzzyLite v.1.01}}
In order to build the graphical user interface of \fl, it is necessary to first
install \texttt{Qt} which can be freely downloaded from
\url{http://qt.nokia.com/}.
	
The \texttt{Makefile} included within the \texttt{./gui} is quite easy to read.
Basically, the most important thing here is to copy the
\texttt{libfuzzylite.dylib} (or whatever the extension be according to your
platform) into the folder \texttt{./gui/dist} which is where the executable will
be put. An alternative is to copy the library into \texttt{/usr/local/lib} and
comment those lines in the \texttt{Makefile} that build and copy the library
into the \texttt{./gui/dist} directory.
	
After configuring the \texttt{Makefile} to fit your system, a \texttt{make all}
from \texttt{./gui} would build the graphical user interface of \fl. To run, it
suffices to execute \texttt{./gui} from \texttt{./gui/dist}.
	
	\section{Acknowledgements}
This work was possible thanks to the Foundation for the Advancement of Soft
Computing, to the Master of Soft Computing and Intelligent Data Analysis, and
especially to Sergio Guadarrama and Luis Magdalena.

